<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>后台登录</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon"/>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/font.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/xadmin.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/lib/layui/layui.js"
            charset="utf-8"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

    <style>
        .btn {
            border: none;
            width: 100%;
            height: 50px;
            outline: 0px;
            font-size: 16px;
            font-weight: 500;
            cursor: pointer;
        }
    </style>
</head>
<body class="login-bg">
    
    <div class="login layui-anim layui-anim-up">
        <div class="message">账号密码登录</div>
        <div id="darkbannerwrap"></div>
        
        <form method="post" class="layui-form" >
            <input name="userName" placeholder="请输入账户名"  maxlength="18" value="admin"  type="text" lay-verify="userName" class="layui-input" >
            <hr class="hr15">
            <input name="userPassword" lay-verify="password" maxlength="12" value="123456" placeholder="请输入密码"  type="password" class="layui-input">
            <hr class="hr15">
            <input value="登录" lay-submit lay-filter="login" style="width:100%;" type="submit">
            <hr class="hr20" >
        </form>
        <button class="btn" onclick="window.location.href='${pageContext.request.contextPath}/login/byPhonePage'">手机号登录</button>
    </div>

    <script>

        $(function  () {
            layui.use('form', function(){
                $ = layui.jquery;
                var form = layui.form
                    , layer = layui.layer;

                //自定义验证规则
                form.verify({
                    userName:[/[\u4e00-\u9fa5_a-zA-Z0-9_]{2,8}/, "用户名必须2-8位字符"] ,
                    password: [/(.+){6,12}$/, '密码必须6到12位']
                });

              //监听提交
              form.on('submit(login)', function(data){
                  // 提交数据到后台
                  $.ajax({
                      type:"post",
                      url:"${pageContext.request.contextPath}/login/byName",
                      data: data.field,
                      dataType:"json",
                      success:function (json) {
                          layer.msg(json.msg,{icon: json.code === 200 ? 6 : 5}, function(){
                              if(json.code === 200){
                                  location.href='${pageContext.request.contextPath}/index/page';
                              }
                          });
                      }
                  });
                return false;
              });
            });
        });

        
    </script>

    
    <!-- 底部结束 -->

</body>
</html>